class WorkExperience implements Cloneable{//Cloneable只是起到标记的作用（标记为可克隆的），内部没有规约必须实现的功能
    private String workDate;
    private String company;

    public void setWorkDate(String workDate,String company) {
        this.workDate = workDate;
        this.company = company;
    }
    public String getWorkDate(){
        return workDate;
    }
    public String getCompany(){
        return company;
    }
//    工作经历对象对自己的克隆
    public Object clone(){
        WorkExperience obj=new WorkExperience();
        obj.workDate=this.workDate;
        obj.company=this.company;
        return obj;
    }
}
class Resume implements Cloneable{
    private String name;
    private String gender;
    private String age;
    private WorkExperience work;

    public Resume(String name) {
        this.name = name;
        this.work=new WorkExperience();
    }
    private Resume(WorkExperience work){
        this.work=(WorkExperience) work.clone();
    }
    public void setPersonalInfo(String gender,String age){
        this.gender=gender;
        this.age=age;
    }
    public void setWork(String worDate,String company){
        this.work.setWorkDate(worDate,company);
    }
//    克隆自己
    public Object clone(){
//        Resume obj=new Resume(this.name);
        Resume obj=new Resume(this.work);
        obj.gender=this.gender;
        obj.age=this.age;
//        obj.work=this.work;//浅复制
//        obj.work=(WorkExperience) this.work.clone();//深克隆
        return obj;
    }
}
public class Test {
    public static void main(String[] args) {
        Resume a=new Resume("张三");
        a.setPersonalInfo("男","18");
        a.setWork("2000-2005","比特培训");

        Resume b=(Resume) a.clone();
    }
}
